# -*- coding: utf-8 -*-
import os

###########################################################################
## Python code generated with wxFormBuilder (version Oct 26 2018)
## http://www.wxformbuilder.org/
##
## PLEASE DO *NOT* EDIT THIS FILE!
###########################################################################

import wx
import wx.xrc


###########################################################################
## Class MyFrame1
###########################################################################

class MyFrame1(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, id=wx.ID_ANY, title='XPS 转 PDF', pos=wx.DefaultPosition,
                          size=wx.Size(824, 361), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)

        self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)

        bSizer1 = wx.BoxSizer(wx.VERTICAL)

        self.m_bitmap1 = wx.StaticBitmap(self, wx.ID_ANY, wx.Bitmap("F:\\xpstopdf.png", wx.BITMAP_TYPE_PNG),
                                         wx.DefaultPosition, wx.Size(-1, 100), 0)

        bSizer1.Add(self.m_bitmap1, 0, wx.ALL, 5)

        fgSizer2 = wx.FlexGridSizer(0, 5, 0, 0)
        fgSizer2.SetFlexibleDirection(wx.BOTH)
        fgSizer2.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.m_staticText2 = wx.StaticText(self, wx.ID_ANY, u"操作目录", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_staticText2.Wrap(-1)

        fgSizer2.Add(self.m_staticText2, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        self.m_dir_xps = wx.DirPickerCtrl(self, wx.ID_ANY, wx.EmptyString, u'现在', wx.DefaultPosition,
                                          wx.Size(300, -1), wx.DIRP_DEFAULT_STYLE,wx.DefaultValidator, u"你好")
        self.m_dir_xps.SetFont(
            wx.Font(wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL,
                    False, "@仿宋"))
        fgSizer2.Add(self.m_dir_xps, 0,  wx.ALIGN_CENTER_HORIZONTAL | wx.ALL | wx.EXPAND, 5)

        self.m_staticText1 = wx.StaticText(self, wx.ID_ANY, u"输出目录", wx.DefaultPosition, wx.DefaultSize, 0)
        self.m_staticText1.Wrap(-1)
        fgSizer2.Add(self.m_staticText1, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        self.m_dir_pdf = wx.DirPickerCtrl(self, wx.ID_ANY, wx.EmptyString, u"Select a folder", wx.DefaultPosition,
                                          wx.Size(300, -1), wx.DIRP_DEFAULT_STYLE)
        fgSizer2.Add(self.m_dir_pdf, 0, wx.ALL, 5)

        self.m_button2 = wx.Button(self, wx.ID_ANY, u"xps 转 pdf", wx.DefaultPosition, wx.DefaultSize, 0)
        fgSizer2.Add(self.m_button2, 0, wx.ALL, 5)

        bSizer1.Add(fgSizer2, 0, wx.EXPAND, 5)

        bSizer2 = wx.BoxSizer(wx.VERTICAL)

        self.m_textCtrl1 = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize,  wx.TE_MULTILINE|wx.HSCROLL|wx.VSCROLL )
        self.m_textCtrl1.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
        self.m_textCtrl1.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))
        self.m_textCtrl1.SetMinSize(wx.Size(800, 600))
        bSizer2.Add(self.m_textCtrl1, 0, wx.ALL|wx.EXPAND, 5)

        bSizer1.Add(bSizer2, 1, wx.EXPAND, 5)

        self.SetSizer(bSizer1)
        self.Layout()

        self.Centre(wx.BOTH)

        self.m_button2.Bind(wx.EVT_LEFT_DOWN, self.submitLeftDown)
        self.m_dir_xps.Bind(wx.EVT_DIRPICKER_CHANGED, self.m_dirPicker3OnKeyUp)
        self.m_dir_pdf.Bind(wx.EVT_DIRPICKER_CHANGED, self.m_dirPicker3OnKeyUpPdf)

    def __del__(self):
        pass

    def param_init(self):
        self.pdfVal = ''
        self.xpsVal = ''
        self.textVal= ''


    def submitLeftDown(self,event):
        print(';plllllllllll')
        print(self.m_dir_pdf.GetPath())
        print(self.m_dir_xps.GetPath())

    def m_dirPicker3OnKeyUp(self,event):
        print(';EVT_MOUSEWHEEL')
        ll = self.m_dir_xps.GetClassDefaultAttributes()
        self.xpsVal = self.m_dir_xps.GetPath()
        self.m_textCtrl1.AppendText('待处理文件夹：'+self.xpsVal + os.linesep)
        if self.pdfVal == '':
            print('------->')
            self.pdfVal = self.xpsVal
            self.m_dir_pdf.SetPath(self.pdfVal)
            self.m_textCtrl1.AppendText('处理后文件夹：'+self.pdfVal + os.linesep)

    def m_dirPicker3OnKeyUpPdf(self,event):
        self.pdfVal = self.m_dir_pdf.GetPath()
        self.m_textCtrl1.AppendText('处理后文件夹：'+self.pdfVal + os.linesep)

    def getValue(self):
        self.pdfVal = self.m_dir_pdf.GetPath()
        self.xpsVal = self.m_dir_xps.GetPath()